﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B.MES.Customer.Domain.DTO
{
    public class APIResult<T> where T : class
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public int Code { get; set; }
        /// <summary>
        /// 消息
        /// </summary>
        public string Message { get; set; }
        /// <summary>
        /// 消息
        /// </summary>
        public int ids { get; set; }

        /// <summary>
        /// 数据
        /// </summary>
        public T Data { get; set; }
        /// <summary>
        /// token
        /// </summary>
        public string Token { get; set; }
        /// <summary>
        /// 总条数
        /// </summary>
        public int totalCount { get; set; }

        public void Success(T data, string message = "成功", int code = 200)
        {
            Code = code;
            Message = message;
            Data = data;
        }

        public void Success(int code = 200,string message = "添加成功")
        {
            Code = code;
            Message = message;
        }

        public void SuccessDel()
        {
            Code = 200;
            Message = "删除成功";
        }
        public void SuccessUpdate()
        {
            Code = 200;
            Message = "修改成功";
        }
        public void Error(string message, int code = 500)
        {
            Code = code;
            Message = message;
        }

        public void Success()
        {
            Code = 200;
            Message = "添加成功";
        }
    }
}
